<?php
session_start();
include("../include/config.inc.php");
include("../include/version.inc.php");
include("../include/tables.inc.php");
include("../include/funktion.inc.php");
include("../include/rights.inc.php");


if(!isset($_SESSION['userid']))
   weiterleitung("index.php");

$rights = $_SESSION['ses_rights'];
$menu = menu($rights);
$was = $_GET['was'];
$fehler = "";

if($was == 'save')
   {
   $pw_old = md5($_POST['pw_old']);
   $pw = md5($_POST['pw']);
   $pw2 = md5($_POST['pw2']);

   $abfrage = "SELECT `pw` FROM `$userdb` WHERE `id` = '".$_SESSION['userid']."'";
   $ergebnis = mysql_query($abfrage);
   $row = mysql_fetch_row($ergebnis);


   if($pw_old != $row[0])
      $fehler = "Altes Passwort nicht korrekt";
   else if($pw != $pw2)
      $fehler = "Passw&ouml;rter stimmen nicht &uuml;berein";
   else if($_POST['pw'] == "")
      $fehler = "Bitte ein neues Passwort w&auml;hlen";
   else
      {
      $aendern = "UPDATE `$userdb` SET `pw` = '$pw' WHERE `id` = '".$_SESSION['userid']."'";
      $update = mysql_query($aendern);
      $fehler = "Passwort wurde ge&auml;ndert";
      }



   }

?>


<html>
<head>
<title>Clanletter - Admin Bereich</title>
<meta name="author" content="Andavos">
<style type="text/css">
<!--
a:hover { text-decoration:none; }

BODY {

     SCROLLBAR-FACE-COLOR: #4F5271;
     SCROLLBAR-HIGHLIGHT-COLOR: #243D62;
    SCROLLBAR-SHADOW-COLOR: rgb(32,32,32);
    SCROLLBAR-ARROW-COLOR: #ffffff;

}

.anhang {
 font-size: 14px;
 color: #000000;
 background-color: #899FBF;

 border-color: #000000;
 border-top-width :1pt;
 border-right-width : 1px;
 border-bottom-width : 1px;
 border-left-width : 1px;
}

-->
</style>


</head>
<body text="#000000" bgcolor="#D0D0D0" link="#000060" alink="#000060" vlink="#000060">


<table cellpadding="5" cellspacing="2"  bgcolor="black" align="center" width="85%">
<tr>
 <td width="205" valign="top" bgcolor="#899FBF"><a target="_blank" href="http://www.php-einfach.de"><img src="php-einfach.jpg" width="199" height="66" border="0" alt="PHP-Einfach.de"></a> <br>


 <?php echo $menu; ?>


<font size="-1"> <a target="_blank" href="http://www.php-einfach.de">&copy; PHP-Einfach.de Clanletter 2.0</a><br>
 </td>
  <td valign="top" bgcolor="#9BAAC1">
<div align="center"><h2>Passwort &auml;ndern</h2></div>

<center><font color="#BD0000"><b><?php echo $fehler; ?></b></font></center>

<form action="?was=save" method="post" target="">
<b>Altes Passwort:</b><br>
<input type="Password" name="pw_old" value="" size="25" maxlength="60"><br><br>

<b>Neues Passwort:</b><br>
<input type="Password" name="pw" value="" size="25" maxlength="60"><br><br>

<b>Neues Passwort: (<small>Wiederholen</small>)</b><br>
<input type="Password" name="pw2" value="" size="25" maxlength="60"><br><br>

&nbsp;&nbsp;<input type="Submit" name="" value="Speichern">


</form>

  </td>
</tr>
</table>

</body>
</html>
